import { ADD_PERSON } from "../constant";

const initState = [{
    id: 1,
    name: 'tom',
    age: 18
}];

export default function personReducer(preState = initState, action) {
    // console.log(initState);
    const {type, data} = action;
    switch(type) {
        case ADD_PERSON:
            // return preState.push(data);
            return [data, ...preState];
        default:
            return preState;
    }
}